package com.gxa.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.gxa.common.JsonResult;
import com.gxa.service.RoleService;
import com.gxa.service.impl.RoleServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/role/search")
public class SearchRoleServelt extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Integer currentpage = Integer.parseInt(req.getParameter("page"));
        Integer pagesize = Integer.parseInt(req.getParameter("limit"));
        String role_name = req.getParameter("role_name");
        System.out.println(role_name);
        RoleService roleService = new RoleServiceImpl();
        JsonResult jsonResult = roleService.queryRoleList(currentpage, pagesize, role_name);
        Object data = jsonResult.getData();
        System.out.println(data);
        resp.setContentType("application/json;charset=utf-8");
        resp.getWriter().write(JSONObject.toJSONString(jsonResult));
    }
}
